<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<div>
	<form action="${pageContext.request.contextPath}/prconfig/add" method="get" class="pageForm required-validate"
  		 onsubmit="return iframeCallback(this,navTabAjaxDone);">
		<div layouth="56" class="pageFormContent" style="height:186px; overflow: auto;">
			<table class="list" width="100%" layoutH="116">
				<thead>
					<tr>
						<th width="80">
							<input class="checkboxCtrl" id="checkbox_all" type="checkbox" group="prId">
						</th>
						<th width="80">油品标准</th>
						<th width="80">油品名</th>
					</tr>
				</thead>
			<tbody>
				<volist id="vo" name="list">
					<c:forEach items="${list}" var="bean" varStatus="status">
						<tr target="sid_user" rel="${bean.id}">
							<td id="prid_td_${bean.id}">
								<input type="checkbox" id="prId" name="prId"  value="${bean.id}"/>
							</td>
							<td>${bean.standard}</td>
							<td>${bean.name}</td>
						</tr>
					</c:forEach>
					</volist>
				</tbody>
			</table>
		<input type="hidden" id="hqId" checked="hqId" value="${hqId }"/>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="button" onclick="submint_form()">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button class="close" type="button">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
<script type="text/javascript">
	$(function(){
		var hqId = $("#hqId").val();
		$.ajax({
			type : "post",
			url : "${pageContext.request.contextPath}/prconfig/listPRConfigByHqId",
			data : {hqId:hqId},
			dataType : "json",
			async : true,
			success : function(data) {
				if(data.code*1 == 200){
					json = eval(data.list);  
				  for(var i=0; i<json.length; i++){  
					  $("#prid_td_"+json[i]).find(":checkbox").attr("checked", true)
				  }  
				}else{
					alert(messageValue == 1?false:true);
					$(doc).attr("checked",messageValue == 1?false:true);
				}
			}
		});
	});
	function submint_form(){
		var prIds = $("tbody").find('input[type=checkbox]:checked').map(function(){return this.value;}).get().join(',');
		var hqId = $("#hqId").val();
		$.ajax({
			type : "post",
			url : "${pageContext.request.contextPath}/prconfig/modify",
			data : {hqId:hqId,prIds:prIds},
			dataType : "json",
			async : true,
			success : function(data) {
				if(data.code*1 == 200){
					json = eval(data.list);  
					alertMsg.correct("设置成功");
					//关闭当前窗口
					navTab.closeCurrentTab();
				}else{
					alertMsg.error(data.msg);
				}
			}
		});
	}

</script>

</div>


